package com.yh.ssm.controller;

import com.yh.ssm.common.Result;
import com.yh.ssm.query.TtopicQuery;
import com.yh.ssm.service.TTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: TTopicController.java [贴子处理器]
 * @author: yuhui
 * @version: 1.0.0
 * @Description: TODO
 * @createTime: 2021年04月29日 09:53:00
 */
@RestController
@RequestMapping("tt")
public class TTopicController {
    @Autowired
    private TTopicService tTopicService;

    /**
     * @description: 只显示帖子标题
     * @author: YH 
     * @modifyTime: 2021/4/29 10:16
     */
    @RequestMapping("list/{page}")
    public Result list(@PathVariable("page") Integer page,String title, TtopicQuery ttopicQuery){
        ttopicQuery.setPage(page);
        ttopicQuery.setTitle(title);
        Result info = tTopicService.getInfo(ttopicQuery);
        return info;
    }

    @RequestMapping("list/{page}/{title}")
    public Result list_search(@PathVariable("page") Integer page,@PathVariable("title")String title, TtopicQuery ttopicQuery){
        Result list = list(page, title, ttopicQuery);
        return list;
    }

    @RequestMapping("Pegar/{tid}/{page}")
    public Result getTopic(@PathVariable("tid") Integer tid,@PathVariable("page") Integer page,TtopicQuery ttopicQuery){
        ttopicQuery.setPage(page);
        ttopicQuery.setTid(tid);
        Result infoById = tTopicService.getInfoById(ttopicQuery);
        return infoById;
    }

}
